package com.aijle.videopaper.util;

public class Util {
    /**
     * 获取一个四元素
     * @param Q
     * @param rv
     */
    public static void getQuaternionFromVector(float[] Q, float[] rv) {
        if (rv.length >= 4) {
            Q[0] = rv[3];
        } else {
            Q[0] = 1 - rv[0]*rv[0] - rv[1]*rv[1] - rv[2]*rv[2];
            Q[0] = (Q[0] > 0) ? (float) Math.sqrt(Q[0]) : 0;
        }
        Q[1] = -rv[0];
        Q[2] = -rv[1];
        Q[3] = -rv[2];
    }
}
